﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.Infrastructure;
using DLM.Domain.Model;

namespace DLM.Data.EF.CodeFirst.Mapping
{
    public class PhotoMap : EntityTypeConfiguration<Photo>
    {
        public PhotoMap()
        {
            this.HasKey(t => t.PhotoID);
            this.ToTable("Photo");
            this.Property(t => t.PhotoID).HasColumnName("PhotoID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.Url).HasColumnName("Url").HasMaxLength(30);
            this.Property(t => t.Desc).HasColumnName("Desc").HasMaxLength(20);
            this.Property(t => t.IsMain).HasColumnName("IsMain");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.HasRequired(t => t.User).WithMany(t => t.Photos).HasForeignKey(d => d.UserID);
        }
    }
}
